Skip to content

Fix: The monitor's screen size is incorrect.#623

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
GongHeng2017:202603241055-master-fix
Mar 25, 2026
Merged

Fix: The monitor's screen size is incorrect.#623
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
GongHeng2017:202603241055-master-fix

Conversation

@GongHeng2017
Copy link
Contributor

@GongHeng2017 GongHeng2017 commented Mar 24, 2026

-- For some monitors, detailed size information is not recorded in the EDID file;
in such cases, obtaining the basic size information is sufficient.
-- Therefore, remove the logic that retrieves the detailed size information again.

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-354275.html

Summary by Sourcery

Correct EDID-based screen size parsing and improve handling of invalid EDID data.

Bug Fixes:

  • Fix incorrect screen size calculation by correcting detailed timing parsing for big-endian EDID data and relying on basic size fields when detailed data is missing or inconsistent.
  • Prevent invalid EDID blocks from being processed by aborting parsing on setEdid failure and logging an error message.

Enhancements:

  • Clarify EDID header error messages for little-endian and big-endian modes and remove noisy debug logging from EDID parsing.

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 24, 2026

Reviewer's Guide

Adjusts EDID parsing to handle little/big endian detailed timing bytes correctly, removes a redundant secondary size-calculation path, tightens EDID header validation messages, and makes EDID parsing failure abort parsing for that EDID entry with proper logging.

Sequence diagram for EDID parsing with header validation and abort-on-failure

sequenceDiagram
    actor Caller
    participant CommonTools
    participant EDIDParser

    Caller->>CommonTools: parseEDID(allEDIDS, input, isHW)
    loop for each edidStr in allEDIDS
        CommonTools->>EDIDParser: EDIDParser edidParser
        CommonTools->>EDIDParser: setEdid(edidStr, errorMsg, ch, littleEndianMode)
        alt invalid EDID header
            EDIDParser-->>CommonTools: return false
            CommonTools->>CommonTools: qCritical() << errorMsg
            CommonTools->>CommonTools: continue to next edidStr
        else valid EDID
            EDIDParser-->>CommonTools: return true
            CommonTools->>EDIDParser: vendor()
            CommonTools->>EDIDParser: serialNumber()
            CommonTools->>EDIDParser: monitorName()
            CommonTools->>EDIDParser: screenSize()
            CommonTools->>CommonTools: mapInfo.insert(...)
        end
    end
    CommonTools-->>Caller: parsed EDID info map
Loading

Updated class diagram for EDIDParser and CommonTools EDID parsing

classDiagram
    class EDIDParser {
        - bool m_LittleEndianMode
        - int m_Width
        - int m_Height
        - QString m_ScreenSize
        + EDIDParser()
        + bool setEdid(QString edid, QString errorMsg, QString ch, bool littleEndianMode)
        + void parseScreenSize()
        + QString vendor()
        + QString serialNumber()
        + QString monitorName()
        + QString screenSize()
    }

    class CommonTools {
        + static void parseEDID(QStringList allEDIDS, QString input, bool isHW)
    }

    CommonTools ..> EDIDParser : uses

    note for EDIDParser "parseScreenSize now interprets detailed timing bytes differently for littleEndianMode and big endian mode and no longer recalculates screen size via an alternative path"
Loading

File-Level Changes

Change Details Files
Refine EDID header validation and error reporting in EDIDParser::setEdid.
  • Remove debug log printing little-endian mode at the start of setEdid.
  • Change little-endian EDID header failure message to explicitly mention little endian mode.
  • Change big-endian EDID header failure message to explicitly mention big endian mode.
deepin-devicemanager/src/Tool/EDIDParser.cpp
Fix screen size computation from EDID detailed timing for big-endian mode and simplify size parsing logic.
  • Document the meaning of bytes 66-68 in the detailed timing block and their use for width/height parsing.
  • Adjust byte access and concatenation logic in big-endian mode so width/height high and low bits are combined correctly.
  • Remove the fallback width/height recomputation path that re-parsed bytes 66-68 with different arithmetic, ensuring basic and detailed timing logic are not applied twice.
  • Remove an extra debug log that printed the parsed screen size at the end of parseScreenSize.
deepin-devicemanager/src/Tool/EDIDParser.cpp
Ensure EDID parsing errors skip invalid EDID entries with critical logging in CommonTools::parseEDID.
  • Check the return value of EDIDParser::setEdid and on failure log the errorMsg with qCritical.
  • Skip further processing for a given EDID entry when setEdid fails by continuing to the next iteration.
deepin-devicemanager/src/Tool/commontools.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions
Copy link

  • 敏感词检查失败, 检测到1个文件存在敏感词
详情
{
    "deepin-devicemanager/src/Tool/commontools.cpp": [
        {
            "line": "        return \"https://driver.uniontech.com/api/v1/drive/search\";",
            "line_number": 177,
            "rule": "S35",
            "reason": "Url link | 162cef9d4a"
        },
        {
            "line": "        return \"https://driver.uniontech.com/api/v1/drive/search\";",
            "line_number": 182,
            "rule": "S35",
            "reason": "Url link | 162cef9d4a"
        },
        {
            "line": "        return \"https://drive-pre.uniontech.com/api/v1/drive/search\";",
            "line_number": 185,
            "rule": "S35",
            "reason": "Url link | 0e010283c1"
        }
    ]
}

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • In parseScreenSize, there are still several hard-coded byte indices and magic numbers (e.g., getBytes(4,2/3/4/5), 15H/16H), which would be easier to maintain and reason about if they were wrapped in named constants or small helper functions describing the EDID field semantics.
  • The error messages added to setEdid and the qCritical() log in parseEDID are plain English literals; if these can surface to users, consider routing them through the existing translation mechanism (e.g., QObject::tr) and/or logging category (qCWarning/qCCritical(appLog)) for consistency with the rest of the file.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `parseScreenSize`, there are still several hard-coded byte indices and magic numbers (e.g., `getBytes(4,2/3/4/5)`, `15H/16H`), which would be easier to maintain and reason about if they were wrapped in named constants or small helper functions describing the EDID field semantics.
- The error messages added to `setEdid` and the `qCritical()` log in `parseEDID` are plain English literals; if these can surface to users, consider routing them through the existing translation mechanism (e.g., `QObject::tr`) and/or logging category (`qCWarning/qCCritical(appLog)`) for consistency with the rest of the file.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@GongHeng2017 GongHeng2017 force-pushed the 202603241055-master-fix branch from 49b25d9 to a362d30 Compare March 25, 2026 05:36
@github-actions
Copy link

  • 敏感词检查失败, 检测到1个文件存在敏感词
详情
{
    "deepin-devicemanager/src/Tool/commontools.cpp": [
        {
            "line": "        return \"https://driver.uniontech.com/api/v1/drive/search\";",
            "line_number": 177,
            "rule": "S35",
            "reason": "Url link | 162cef9d4a"
        },
        {
            "line": "        return \"https://driver.uniontech.com/api/v1/drive/search\";",
            "line_number": 182,
            "rule": "S35",
            "reason": "Url link | 162cef9d4a"
        },
        {
            "line": "        return \"https://drive-pre.uniontech.com/api/v1/drive/search\";",
            "line_number": 185,
            "rule": "S35",
            "reason": "Url link | 0e010283c1"
        }
    ]
}

@GongHeng2017 GongHeng2017 force-pushed the 202603241055-master-fix branch from a362d30 to d601b68 Compare March 25, 2026 05:48
@github-actions
Copy link

  • 敏感词检查失败, 检测到1个文件存在敏感词
详情
{
    "deepin-devicemanager/src/Tool/commontools.cpp": [
        {
            "line": "        return \"https://driver.uniontech.com/api/v1/drive/search\";",
            "line_number": 177,
            "rule": "S35",
            "reason": "Url link | 162cef9d4a"
        },
        {
            "line": "        return \"https://driver.uniontech.com/api/v1/drive/search\";",
            "line_number": 182,
            "rule": "S35",
            "reason": "Url link | 162cef9d4a"
        },
        {
            "line": "        return \"https://drive-pre.uniontech.com/api/v1/drive/search\";",
            "line_number": 185,
            "rule": "S35",
            "reason": "Url link | 0e010283c1"
        }
    ]
}

-- For some monitors, detailed size information is not recorded in the EDID file;
   in such cases, obtaining the basic size information is sufficient.
-- Therefore, remove the logic that retrieves the detailed size information again.

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-354275.html
@GongHeng2017 GongHeng2017 force-pushed the 202603241055-master-fix branch from d601b68 to 35558e5 Compare March 25, 2026 06:07
@github-actions
Copy link

  • 敏感词检查失败, 检测到1个文件存在敏感词
详情
{
    "deepin-devicemanager/src/Tool/commontools.cpp": [
        {
            "line": "        return \"https://driver.uniontech.com/api/v1/drive/search\";",
            "line_number": 177,
            "rule": "S35",
            "reason": "Url link | 162cef9d4a"
        },
        {
            "line": "        return \"https://driver.uniontech.com/api/v1/drive/search\";",
            "line_number": 182,
            "rule": "S35",
            "reason": "Url link | 162cef9d4a"
        },
        {
            "line": "        return \"https://drive-pre.uniontech.com/api/v1/drive/search\";",
            "line_number": 185,
            "rule": "S35",
            "reason": "Url link | 0e010283c1"
        }
    ]
}

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: GongHeng2017, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@GongHeng2017
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Mar 25, 2026

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit a45de1e into linuxdeepin:master Mar 25, 2026
20 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants